﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Provenance.Domain.Product;
using Provenance.ErrorCount;
using Provenance.Read.Api.Application.Command.Product;
using Provenance.Read.Api.Application.Command.Provenance;
using Provenance.Read.Api.Dto.Product;
namespace Provenance.Read.Api.Controllers
{
    [Route("api/provenance/[controller]/[action]")]
    [ApiController]
    public class ProvenanceController : ControllerBase
    {
        private readonly IMediator _mediator;
        public ProvenanceController(IMediator mediator)
        {
            _mediator = mediator;
        }

        [HttpGet]
        public async Task<ApiResult<PagingResult<IList<GetProductInfoResponseDTO>>>> GetProductInfo([FromQuery] GetProductInfoCommand param)
        {
            return await _mediator.Send(param);
        }
        [HttpGet]
        public async Task<ApiResult<BackProductInfoResponseDTO>> BackProductInfo([FromQuery] BackProductInfoCommand param)
        {
            return await _mediator.Send(param);
        }
        /// <summary>
        /// 根据条件获取图片信息
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<IList<GetPictureInfoResponseDTO>>> GetPictureInfo([FromQuery] GetPictureInfoCommand param)
        {
            return await _mediator.Send(param);
        }
        [HttpGet]
        public async Task<ApiResult<IList<GetProductListResponseDTO>>> GetProductList([FromQuery]GetProductListCommand param)
        {
            return await _mediator.Send(param);
        }



    }
}
